import datamodel
from google.appengine.ext import db

def getUserdetails(user):
  query = db.Query(datamodel.Userdetails)
  query.filter('user =', user)
  results = query.get()
  return results
  
def setUserdetails(user, gender = '', sexuality = '', birthdate = '', country = '', city = ''):
  userdetail = datamodel.Userdetails()
  userdetail.user = user
  if gender:
    userdetail.gender = str(gender)
  if sexuality:
    userdetail.sexuality = str(sexuality)
  if birthdate:
    userdetail.birthdate = birthdate
#    userdetail.birthdate = datetime(birthdate) How to make sure, it is a datetime object? casting to datetime doesn't work.
  if country:
    userdetail.country = country
  if city:
    userdetail.city = city
  userdetail.put()
  return userdetail